#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    //设置两个输入框为密码形式
    ui->lineEdit->setEchoMode(QLineEdit::Password);
    ui->lineEdit_2->setEchoMode(QLineEdit::Password);
}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_lineEdit_textEdited(const QString &arg1)
{
    (void)arg1;
    this->Compare();
}

void Widget::on_lineEdit_2_textEdited(const QString &arg1)
{
    (void)arg1;
    this->Compare();
}

void Widget::Compare()
{
    const QString& password1 = ui->lineEdit->text();
    const QString& password2 = ui->lineEdit_2->text();
    if(password1.isEmpty() && password2.isEmpty())
    {
        ui->label->setText("密码为空");

    }
    else if(password1 == password2)
    {
        ui->label->setText("密码一致");
    }
    else
    {
        ui->label->setText("密码不一致");
    }
}
